package cn.edu.scau.cmi.dengzejun.chapter09;

import java.util.*;

public class Exercise01 {
	public static void main(String args[]) {
		String s1 = "apple is 56.7 yuan. banana is 12 yuan. mango is 19.8 yuan";
		String s2 = "soy sauce is 6.7 yuan. salt is 0.8 yuan. tuber mustard is 9.8 yuan";
		Calculate calculate = new Calculate();
		String regex = "[^[-+]?[0-9]*\\.?[0-9]+$]";
		String s1Number = s1.replaceAll(regex, " * ");
//		System.out.println(s1Number);
		double priceSum = calculate.compute(s1Number, " * ");
		System.out.printf("the total of \" %s  \" is \n%f yuan \n",s1,priceSum);
		String s2Number = s2.replaceAll(regex," # ");
		priceSum = calculate.compute(s2Number, " # ");
		System.out.printf("the total of \" %s \" is \n%f yuan \n", s2,priceSum);
		return;
	}
}
